package vocabularyhub.word.mw.process;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.apache.log4j.Logger;

import vocabularyhub.io.impl.SimplestReader;
import vocabularyhub.word.model.IWord;
import vocabularyhub.word.process.util.SerializeUtil;

public class WMHuber {
    static Logger logger = Logger.getLogger(WMHuber.class);
    List<IWord> words = null;

    public static void main(String args[]) throws ClientProtocolException,
    FileNotFoundException, IOException {

        new WMHuber().huberProcess();
    }

    public void huberProcess() throws ClientProtocolException,
    FileNotFoundException, IOException {

        File inputFile = new File("contents/redCore.txt");
        File outputFile = new File("contents/redCore.bin");
        prepareWMPersistence(inputFile, outputFile);

    

    }

    private void prepareWMPersistence(File input, File output)
    throws ClientProtocolException, FileNotFoundException, IOException {
        this.save(read(input), output);
    }

    private List<IWord> read(File file) throws FileNotFoundException {
        List<IWord> words = new SimplestReader().parseWordListFile(file);
        return words;
    }

    private void save(List<IWord> words, File file)
    throws ClientProtocolException, IOException {
        List<IWord> thesaurusWords = WordThesaurusProcessor.getInstance()
        .getWords(words);

        SerializeUtil.serialize(file, thesaurusWords);

    }

}
